<template>
    <el-cascader
            v-model="props.catalogId"
            :options="options"
            :props="caprops"
            filterable
            placeholder="试试搜索"
            @change="handleChange"
    />
</template>

<script setup>
    import {ref,  reactive, onMounted} from 'vue'
    import request from '@/utils/request.js'
    let options = reactive([])
    let caprops = {value:"catId", label:"name"}
    let props = defineProps(['catalogId'])
    let emits = defineEmits(['selectCatalogId'])
    onMounted(() => {
        request.get("/api/category/list/tree").then(resp => {
            options.push(...resp)
        });
    })
    function handleChange(node) {
        emits("selectCatalogId", node[node.length-1])
    }
</script>

<style scoped>

</style>